from flask import Flask,request

app=Flask(__name__)

@app.route('/')
def index():
    return 'hello,world'

@app.route('/pang')
@app.route('/mao')
def hello_pm():
    return '<h1>hello,胖猫!<h1>'

#动态路由
@app.route('/user/<username>',methods=['GET','POST'])
def user_profile(username):
    if request.method == 'POST':
        return f'用户{username}的个人资料'


@app.route('/hi',methods=['POST'])
def hi_world():
    return '<h1>hi,world!<h1>'

#闭包
@app.route('/name/<name>')
def name_profile(name):
    message=name
    def in_name_profile():
        return f'<h1>你好，尊贵的:{message} </h1>'
    return in_name_profile()
    
        


if __name__=="__main__":
    app.run()
